<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<h1 class="page-title">员工资料管理</h1>
<table class="display" id="example">
    <thead>
    <tr>
        <th>选择</th>
        <th>员工工号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>出生日期</th>
        <th>身份证号码</th>
        <th>部门</th>
        <th>职务</th>
        <th>职等</th>
        <th>户籍</th>
        <th>档案所在地</th>
    </tr>
    </thead>
    <tbody>
    <s:if test="#request.employeeinfoWorks==null || #request.employeeinfoWorks.size==0">
        <tr class="gradeA">
            <td colspan="11">没有数据</td>
        </tr>
    </s:if>
    <s:iterator value="employeeinfoWorks" var="reg" status="sta">
        <s:if test="#sta.even">
            <tr class="gradeA">
        </s:if>
        <s:else>
            <tr class="gradeC">
        </s:else>
        <td><input type="checkbox" name="check_staff" value="${reg.id}"/></td>
        <td><a href="#employee/staff_view.xhtml?id=${reg.id}">${reg.workNo}</a></td>
        <td>${reg.baseId.name}</td>
        <td>${reg.baseId.sex=="0"?"男":"女"}</td>
        <td><s:date name="#reg.baseId.birthday" format="yyyy/MM/dd"/></td>
        <td>${reg.baseId.idcard}</td>
        <td>${reg.organization.fullName}</td>
        <td>${reg.duty.dutyName}</td>
        <td>${reg.grade.gradeName}</td>
        <td>${reg.baseId.census}</td>
        <td>${reg.baseId.archives}</td>
        </tr>
    </s:iterator>
    </tbody>
</table>
<p>
    <%@ include file="/WEB-INF/pages/common/main_orgtab_pager.jsp" %>
</p>

<script type="text/javascript">

    //删除员工
    function deleteEmployees() {
        var checkIds = new Array();
        $("input[type='checkbox'][name='check_staff']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            return;
        }
        if (confirm("确定要删除选中的数据吗？删除后将无法恢复!")) {
            doDeleteEmps(checkIds.join(","))
        }
    }

    function doDeleteEmps(ids) {
        var url = "${ctx}/employee/staff_delete.xhtml";
        $.ajax(url, {
            type: "POST",
            data:{"empIds":ids},
            dataType:"html",
            cache:false,
            success:function(a) {
                var obj = $("#list_content_" + currentTabOrgId);
                obj.html("");
                obj.append(a);
            },
            complete:function() {

            }
        });

    }

    //选择员工更新
    function updateSelectedEmployees() {
        var checkIds = new Array();
        $("input[type='checkbox'][name='check_staff']").each(function() {
            if (this.checked) {
                checkIds.push(this.value);
            }
        });
        if (checkIds.length == 0) {
            //alert("请选择一个人员信息");
            return;
        }

        if (checkIds.length > 1) {
            alert("每次只能更新一个人员信息");
            return;
        }
        var url = "#employee/staff_edit.xhtml?id=" + checkIds[0] + "&organizationId=" +${organizationId};
        window.location.href = url;

    }

    function addEmployee(){
        var orgId=$("#current_organization_id").val();   
        window.location.href = "#employee/staff_add.xhtml?organizationId="+orgId;
    }

    function exportEmployees(){

    }
</script>